import 'package:flutter/material.dart';
import 'package:flutter_bilibili/model/home_model.dart';
import 'package:flutter_bilibili/util/format_util.dart';
import 'package:flutter_bilibili/widget/hi_banner.dart';
import 'package:flutter_bilibili/util/view_util.dart';

class NoticeCard extends StatelessWidget {
  final BannerMo mo;

  const NoticeCard({Key key, @required this.mo}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () => handleClick(mo),
      child: Container(
        decoration: BoxDecoration(border: borderLine(context)),
        padding: EdgeInsets.only(left: 15, right: 15, bottom: 10, top: 5),
        child: Row(
          children: [_buildIcon(),Padding(padding: EdgeInsets.only(right: 10)),_buildContents()],
        ),
      ),
    );
  }

  _buildIcon() {
    var iconData = mo.type == 'video'
        ? Icons.ondemand_video_outlined
        : Icons.card_giftcard;
    return Icon(iconData,size: 30);
  }

  _buildContents(){
    return Flexible(
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Text(mo.title,style: TextStyle(fontSize: 16)),
              Text(dateMonthAndDay(mo.createTime))
            ],
          ),
          hiSpace(height: 5),
          Text(mo.subtitle,maxLines: 1,overflow: TextOverflow.ellipsis)
        ],
      )
    );
  }
}
